const _function = require("../../utils/functionData")
Page({
  data: {
    isRefreshing: false,
    isLoading: false,
    hasMore: true,
    page: 1,
    orderList: [
      // 示例数据
      {
        id: 1,
        teacherName: "王教授",
        identity: "博士生导师",
        type: "学术指导",
        time: "2024-03-01 14:30",
        status: "success"
      }
    ]
  },
  onLoad(options) {
    this.getBookTeacherList()
  },
  getBookTeacherList() {
    console.log('获取社团详情');
    const params = {
      studentId: getApp().globalData.userInfo.userId
    }
    _function.getBookTeacherList(params, this.getBookTeacherListBack, this)
  },
  getBookTeacherListBack(res) {
    let dataAll = res.data
    if (dataAll.code == 200) {
      this.setData({
        orderList: dataAll.rows
      })
      console.log('消息列表', dataAll.data);
    }
  },
  // 下拉刷新
  onPullDownRefresh() {
    this.setData({ isRefreshing: true });
    // 模拟请求
    setTimeout(() => {
      this.setData({ 
        orderList: [...newData], 
        isRefreshing: false,
        page: 1
      });
      wx.stopPullDownRefresh();
    }, 1500);
  },

  // 上拉加载
  loadMore() {
    if (!this.data.hasMore || this.data.isLoading) return;
    
    this.setData({ isLoading: true });
    // 模拟请求
    setTimeout(() => {
      this.setData({
        orderList: [...this.data.orderList, ...newData],
        page: this.data.page + 1,
        isLoading: false,
        hasMore: this.data.page < 3 // 模拟限制3页
      });
    }, 1000);
  }
});